<?php

namespace app\logic\model\user;

use app\logic\model\LogicModel;

class UserWriterWithdrawLogicModel extends LogicModel
{
    protected $name='user_writer_withdraw';



    function user(){
        return $this->hasOne(UserLogicModel::class,'id','user_id');
    }
    function getList($request,$where=[],$filed="*",$page=1,$limit=15,$order="create_time desc"){
        $query=$this->where($where)
            ->where(function ($q) use ($request){
                if(check_request($request,'nickname')){
                    $q->whereLike("nickname","%{$request['nickname']}%");
                }
                if(check_request($request,'mobile')){
                    $q->whereLike("mobile","%{$request['mobile']}%");
                }
                if(check_request($request,'start_time')&&check_request($request,'end_time')){
                    $q->whereBetween("create_time",[$request['start_time'],$request['end_time']." 23:59:59"]);
                }elseif (check_request($request,'start_time')){
                    $q->where("create_time",">=",$request['start_time']);
                }elseif (check_request($request,'end_time')){
                    $q->where("create_time","<=",$request['end_time']." 23:59:59");
                }
            });
        $list = $query->field($filed)->order($order)
            ->with(['user'])
            ->page($page,$limit)->select()->toArray();
        $count = $query->count();
        return [$list,$count];
    }
}